import type { DataInfo } from "@/utils/auth";
import { HttpClient } from "./core/client";
import type {
  CustomError,
  CustomRequestConfig,
  HookCallback,
  HookType,
  HttpResponse
} from "./core/types";

/**
 * HTTP 客户端实例
 *
 * 所有的HTTP请求都应通过此实例调用，不再提供单独的方法导出。
 *
 * @example
 * // 导入httpClient实例
 * import httpClient from '@/utils/request';
 *
 * // 常用请求方法示例
 * // 发起GET请求
 * httpClient.get('/api/users', { id: 1 });
 *
 * // 发起POST请求
 * httpClient.post('/api/login', { username: 'admin', password: '123456' });
 *
 * // PUT请求
 * httpClient.put('/api/users/1', { name: 'New Name' });
 *
 * // DELETE请求
 * httpClient.delete('/api/users/1');
 *
 * // PATCH请求
 * httpClient.patch('/api/users/1', { name: 'Updated Name' });
 *
 * // 通用请求
 * httpClient.request({
 *   url: '/api/custom',
 *   method: 'post',
 *   data: { custom: 'data' }
 * });
 *
 * // 工具方法
 * // 设置令牌(需要传入完整的TokenData对象)
 * httpClient.setToken({
 *   token: 'your-token',
 *   expire: 3600,
 *   userInfo: {
 *     username: 'admin',
 *     nickname: '管理员'
 *   }
 * });
 * httpClient.clearToken();                 // 清除令牌
 * httpClient.cancelAllRequests();          // 取消所有请求
 * httpClient.enableLog();                  // 启用日志
 * httpClient.disableLog();                 // 禁用日志
 * httpClient.setLogLevel('debug');         // 设置日志级别
 * httpClient.setConfig({ timeout: 5000 }); // 设置配置
 */

// 创建实例
const httpClient = new HttpClient();

// 导出实例作为默认导出
export default httpClient;

// 导出类型
export type {
  CustomError,
  CustomRequestConfig,
  DataInfo,
  HookCallback,
  HookType,
  HttpResponse
};
